﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Threading;
using UnityEngine;

public class _25 : MonoBehaviour
{
    public static List<Student> listStudent = new List<Student>();
    // Start is called before the first frame update
    void Start()
    {
        //引用类型，保存的是一个地址
        StudentTeamA teamA = new StudentTeamA();

        Thread t1 = new Thread(()=> {
            teamA.students = listStudent;
            Thread.Sleep(3000);
            Debug.LogError(listStudent.Count);//报空
            Debug.LogError(teamA.students.Count);//0
        });
        t1.Start();

        Thread t2 = new Thread(()=> {
            listStudent = null;
        });
        t2.Start();
    }

    // Update is called once per frame
    void Update()
    {

    }
}

public class Student
{
    public string Name { get; set; }
    public int Age { get; set; }
}

public class StudentTeamA
{
    public List<Student> students { get; set; }
}

